// ========================================================
// Des：
// Autor：Mr.H 
// CreateTime：2024/03/16 00:34:42
// 版 本：v 1.0
// ========================================================

using UnityEngine;
using UnityEngine.SceneManagement;

public class BeginPanel : BasePanel<BeginPanel>
{
    //首先声明公共的成员变量 来关联各个控件
    public CustomGUIButton btnBegin;
    public CustomGUIButton btnSetting;
    public CustomGUIButton btnQuit;
    public CustomGUIButton btnRank;

    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Confined;//方便控制转向

        //监听一次按钮点击过后要做什么
        btnBegin.clickEvent += () =>
        {
            //切换场景
            AsyncOperation op = SceneManager.LoadSceneAsync("GameScene");
            op.allowSceneActivation = false;
            while (!op.isDone)
            {
                Debug.Log("加载游戏中");
                if (op.progress >= 0.9f)
                {

                    op.allowSceneActivation = true;
                    return;
                }
            }
        };
        btnSetting.clickEvent += () =>
        {
            //打开设置面板
            SettingPanel.Instance.ShowMe();
            //隐藏自己 避免穿透
            HideMe();
        };
        btnQuit.clickEvent += () =>
        {
            //退出游戏
            Application.Quit();
        };
        btnRank.clickEvent += () =>
        {
            //打开排行榜面板
            RankPanel.Instance.ShowMe();
            //避免穿透 隐藏自己
            HideMe();
        };
    }


}
